<?php

namespace app\admin\model\user;

use think\Model;
use think\Db;

class Lever extends Model
{

    

    

    // 表名
    protected $name = 'user_level';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'coupon_text'
    ];


    public function coupon()
    {
        $couponlist = Db::name('shopro_coupon')->order('id desc')->select();
        return $couponlist;
    }
    public function getCouponTextAttr($value, $data)
    {
        $lists = Db::name('shopro_coupon')
            ->whereIn('id', $data['gift_coupon'])
            ->column('name');
        return implode(',', $lists);
    }

    







}
